package controller

import (
	"context"
	"github.com/gin-gonic/gin"
	"net/http"
	"strconv"
	"user_bff/pkg"
	"user_bff/user_proto"
)

// 用户列表
func UserList(c *gin.Context) {
	//var form forms.UserListForm
	//err := c.ShouldBind(&form)
	//if err != nil {
	//	ReturnErrorJson(err, c)
	//	return
	//}
	page := c.Query("page")
	limit := c.Query("limit")
	pageInt, _ := strconv.Atoi(page)
	limitInt, _ := strconv.Atoi(limit)
	comment := pkg.Comment()
	list, err := comment.GetUserList(context.Background(), &user_proto.GetUserListRequest{
		Page:  int64(pageInt),
		Limit: int64(limitInt),
	})
	if err != nil {
		HandleGrpcErrorToHttp(err, c)
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code": 0,
		"msg":  "查询成功",
		"data": list,
	})
}
